package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.domain.TravelCommend;
import cn.wolfcode.trip.base.domain.TravelContent;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.TravelCommendMapper;
import cn.wolfcode.trip.base.mapper.TravelContentMapper;
import cn.wolfcode.trip.base.mapper.TravelMapper;
import cn.wolfcode.trip.base.query.TravelCommendQueryObject;
import cn.wolfcode.trip.base.query.TravelQueryObject;
import cn.wolfcode.trip.base.service.ITravelCommendService;
import cn.wolfcode.trip.base.service.ITravelService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class TravelCommendServiceImpl implements ITravelCommendService {
    @Autowired
    private TravelCommendMapper travelCommendMapper;


    @Override
    public void saveOrUpdate(TravelCommend travelCommend) {
        if (travelCommend.getId() == null) {
            travelCommendMapper.insert(travelCommend);
        } else {
            travelCommendMapper.updateByPrimaryKey(travelCommend);
        }

    }
    @Override
    public PageInfo query(TravelCommendQueryObject queryObject) {
        PageHelper.startPage(queryObject.getCurrentPage(), queryObject.getPageSize(), queryObject.getOrderBy());
        List<TravelCommend>list=travelCommendMapper.selectForList(queryObject);
        return new PageInfo(list);
    }

    @Override
    public TravelCommend selectByPrimaryKey(Long id) {
        return travelCommendMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TravelCommend> listAll() {
        return travelCommendMapper.selectAll();
    }

    @Override
    public PageInfo queryForAppList(TravelCommendQueryObject queryObject) {
        List<TravelCommend>list= travelCommendMapper.selectForAppList(queryObject);

        return new PageInfo(list);
    }


}
